<template>
  <div>
    <el-row class="bg_write">
      <el-row>
        <el-col :span="24" class="content_title">
          <el-col :span="12">
            <HeadTitle></HeadTitle>
          </el-col>
          <el-col :span="12">
          </el-col>
        </el-col>
      </el-row>
    </el-row>
    <el-row class="pd_20">
      <el-table
        ref="multipleTable"
        :data="list_data"
        style="width: 99.9%"
        v-loading="loading"
        stripe
        header-row-class-name="head_color"
        tooltip-effect="dark"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" class="tc" width="35"></el-table-column>
        <el-table-column label="iden" min-width="50">
          <template slot-scope="scope">{{ scope.row.iden}}</template>
        </el-table-column>
        <el-table-column label="标题" min-width="500">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.con"
              @change="list_change($event,scope.row,'con')"
              placeholder="请输入内容"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column label="是否启用" min-width="100">
          <template slot-scope="scope">
            <el-switch
              class="zdySwith"
              :width="82"
              v-model="scope.row.is_show"
              active-color="#1aad19"
              inactive-color="#ffffff"
              active-text="已开启"
              inactive-text="已关闭"
              active-value="1"
              inactive-value="0"
              @change="list_change($event,scope.row,'is_show')"
            ></el-switch>
          </template>
        </el-table-column>
        <el-table-column label="列表显示" min-width="100">
          <template slot-scope="scope">
            <el-switch
              class="zdySwith"
              :width="82"
              v-model="scope.row.is_list"
              active-color="#1aad19"
              inactive-color="#ffffff"
              active-text="已显示"
              inactive-text="已关闭"
              active-value="1"
              inactive-value="0"
              @change="list_change($event,scope.row,'is_list')"
            ></el-switch>
          </template>
        </el-table-column>
        <el-table-column label="修改时间" min-width="200">
          <template slot-scope="scope">{{ scope.row.update_time | getTimeFormat}}</template>
        </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>

<script>
import HeadTitle from "@/components/currency/HeadTitle.vue";
export default {
  name: "auto",
  data() {
    return {
      loading: false,
      list_data: [],
    };
  },
  components: {
    HeadTitle,
  },
  created() {
    this.getList();
  },
  methods: {
    add() {},
    handleSelectionChange() {},
    list_change(e, item, temp) {
      var obj = item;
      if (temp == "con") {
        //标题内容改变
        obj.con = e;
      } else if (temp == "is_show") {
        //is_show开关改变
        obj.is_show = e;
      } else if (temp == "is_list") {
        //is_list开关改变
        obj.is_list = e;
      }
      this.$api.getauto.edit_auto_list(obj).then(res => {
        if (res.data.code == 200) {
          this.$fnc.alertSuccess("修改成功");
          this.getList();
        } else {
          this.$fnc.alertError("修改失败");
        }
      });
    },
    getList() {
      this.loading = true;
      this.$api.getauto.get_auto_list({}).then(res => {
        if (res.data.code == 200) {
          this.loading = false;
          this.list_data = res.data.result;
          console.log(res);
        } else {
          this.loading = false;
        }
      });
    }
  }
};
</script>

<style scoped>
</style>